home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 November / Macworld (1999-11).dmg / Shareware World / Info / For Developers / Smile1.6.6.sea / Smile1.6.6 / Smile ƒ / Help files / Smile dictionary < prev    next >
Text File  |  1999-08-03  |  7KB  |  270 lines

  1. Smile Dictionary
  2.  
  3.  
  4. About Smile dictionary
  5.  
  6. The dictionary of Smile is opened by selecting "Smile dictionary" in the Apple menu.
  7.  
  8. Below is given a summary of the dictionary, which is easier to handle than the complete dictionary itself. Refer to the dictionary for the syntax of any command, and for the complete list.
  9.  
  10. The first four sections below cover functions or commands which can be used in any general AppleScript context.
  11.  
  12. The last sections cover topics specifically intended to handle Smile's objects (windows, dialog boxes ...).
  13.  
  14.  
  15. Remote script handling
  16.  
  17. • execute : run the script contained in a script window
  18. Sample
  19. ----------------------------
  20. execute window "My first script" --> returns the value returned by the script
  21. ----------------------------
  22.  
  23. • check syntax : check syntax of a script window
  24. Sample
  25. ----------------------------
  26. check syntax window "My first script"
  27. ----------------------------
  28.  
  29. • do script : execute a script
  30. Sample
  31. ----------------------------
  32. set nSamples to (do script (AskUser("Enter formula for # of samples 
  33. :", "")))
  34. ----------------------------
  35. Above script allows entering a formula (for instance, 
  36. "100+12*9"), which will be evaluated by "do script".
  37.  
  38.  
  39. AppleScript enhancements
  40.  
  41. • display : return the direct object as a string
  42. Sample
  43. ----------------------------
  44. display (get class of window 1)
  45. ----------------------------
  46.  
  47. • change : replace all occurences of a substring in a document
  48. Sample
  49. ----------------------------
  50. change "a" into "A" in window 2
  51. --  {x, y}  x = number of changes made, y = number of characters in window 2
  52. ----------------------------
  53.  
  54. Note : "change" works on a document, while "replace", a command of the Satimage osax, works on strings. 
  55.  
  56. • extract column : extract a column out of a table
  57. Comments
  58. The table is supposed to be tab-separated (), with rows separated by carriage return characters ( ). The result is returned as a list separated by carriage return characters ( ). You can also obtain the result "as list".
  59. Sample
  60. ----------------------------
  61. extract column 2 in theTable as list
  62. ----------------------------
  63.  
  64. • remote info for : locate an alias on the network
  65. Sample
  66. ----------------------------
  67. remote info for alias theAliasFileAlias
  68. ----------------------------
  69.  
  70.  
  71. Navigation services
  72.  
  73. The commands below use the Navigation Services interface.
  74.  
  75. • navchoose file : choose files
  76. Caution ! Unlike the standard "choose file", this command returns a list.
  77.  
  78. • navchoose folder : choose folder
  79.  
  80. • navask save : prompt for save
  81.  
  82. • navnew file : get a new file specification 
  83.  
  84.  
  85. Clipboard commands
  86.  
  87. • undo
  88.  
  89. • cut
  90.  
  91. • copy 
  92.  
  93. • paste 
  94.  
  95. The clipboard commands are window-specific. Each window has its own undo. So, these commands are to be sent to windows:
  96. ----------------------------
  97. tell window 1 to undo
  98. ----------------------------
  99.  
  100.  
  101. Events sent automatically by Smile
  102.  
  103. • prepare : event sent by the application when an object is created
  104.  
  105. • do menu : event sent by the application when a menu item is selected
  106.  
  107. • click in : event generated by a click in an object
  108.  
  109. • drop : event generated by dropping
  110.  
  111. • export : return a description for the object dragged
  112.  
  113.  
  114. Summary of Smile object classes
  115.  
  116. • Class basic object : generic class which has the properties owned by each object
  117. Properties:
  118.     class type
  119.     name 
  120.     id integer 
  121.     container 
  122.     bounds 
  123.     path name 
  124.     visible 
  125.     script 
  126.     want idle 
  127.     properties 
  128.  
  129. • Class application : (inherits from basic object) the application program
  130. Elements:
  131.     text window
  132.     script window
  133.     dialog
  134.     menu
  135.     menu command
  136. Properties:
  137.     creator type
  138.     cursor
  139.     screen bounds
  140.     extensions path
  141.     user folder
  142.     dictionary
  143.     modifiers
  144.     clipboard
  145.  
  146. • Class window : (inherits from basic object) 
  147.  
  148. • Class text window : (inherits from window) 
  149. Elements:
  150.     character
  151.     text
  152.     international text
  153. Properties:
  154.     selection
  155.     line width
  156.     console
  157.     store undo
  158.     update screen
  159.  
  160. • Class script window : (inherits from text window) 
  161.  
  162. • Class character : 
  163. Properties:
  164.     text size
  165.     text font 
  166.     text color 
  167.     style text 
  168.  
  169. • Class button : (inherits from agent) 
  170.  
  171. • Class menu : 
  172. Elements:
  173.     menu item 
  174. Properties:
  175.     name 
  176.     enabled 
  177.  
  178. • Class menu item : 
  179. Properties:
  180.     name 
  181.     enabled 
  182.     checked 
  183.     modifiers 
  184.     shortcut 
  185.  
  186.  
  187. Text suite - Smile as a scriptable text editor
  188.  
  189. When refering to a substring of text contained in a Smile text document (either to read it, or to overwrite it), you can use the following descriptors : character, word, line, paragraph, text / string.
  190.  
  191. Note the use of line and of paragraph. Paragraph refers to a string terminated by a carriage return, while line refers to a line as wrapped in the window.
  192.  
  193. By default, these descriptors return lists of strings, like AppleScript does :
  194. ----------------------------
  195. words 1 thru 2 of "Smile dictionary"
  196. ----------------------------
  197. will [make AppleScript] return {"Smile", "dictionary"}, while :
  198.  
  199. ----------------------------
  200. words 1 thru 2 of window 1
  201. ----------------------------
  202. will [make Smile] return {"Smile", "dictionary"}.
  203.  
  204. Now, you can coerce these expressions, either to list to get the offsets of the ends of the text chunk, or to text to get its contents. You can also coerce them into styled text, to get the text and its style altogether in one variable.
  205.  
  206. ----------------------------
  207. words 1 thru 2 of window 1 as text
  208. ----------------------------
  209. -- "Smile Dictionary"
  210.  
  211. ----------------------------
  212. words 1 thru 2 of window 1 as list
  213. ----------------------------
  214. --  {0, 16}
  215.  
  216. ----------------------------
  217. set theText to words 1 thru 2 of window 1 as styled text
  218. ----------------------------
  219. -- "Smile Dictionary"
  220. The variable 'theText' contains styled text, which can be copied into another text window.
  221.  
  222. The selection of a text window returns a list. It can also be coerced to text or to styled text.
  223.  
  224. Similarly, by default, the result of a every expression (including possibly a whose clause) is a list of strings. 
  225.  
  226. These descriptors can be used to specify a piece of text according to its position in the window. Coerce it to list if you want the offsets of its ends.
  227.  
  228. ----------------------------
  229. paragraph after words 1 thru 2 of window 1
  230. ----------------------------
  231. -- ""
  232.  
  233. ----------------------------
  234. paragraph after words 1 thru 2 of window 1 as list
  235. ----------------------------
  236. -- {17, 18}
  237.  
  238. Use the 'set' operator to edit the text:
  239.  
  240. ----------------------------
  241. set paragraph after words 1 thru 2 of window 1 to "hello"
  242. ----------------------------
  243.  
  244. ----------------------------
  245. set end of text of window 1 to "hello"
  246. ----------------------------
  247.  
  248.  
  249. Math library
  250.  
  251. cos
  252. sin
  253. acos
  254. asin
  255. tan
  256. atan2
  257. atan
  258. sqrt
  259. ln
  260. log10
  261. exp
  262.  
  263. ========================================================
  264.  
  265. Advanced
  266.  
  267. • If you control-click, or use the "Help" key, when one of the verbs of the Smile dictionary is selected, this will open the Smile dictionary and scroll it so as to put the selected verb in view.
  268.  
  269. ========================================================
  270.